package net.cyndeline.components.slot

import net.cyndeline.entitySystem.Component
import net.cyndeline.entitySystem.EntityRef

trait SpellSlotsComponent extends Component {
  def slots = Array[Option[EntityRef]]()
  def slots_=(slots: Array[Option[EntityRef]])
}

class SpellSlots extends SpellSlotsComponent {
  override var slots = Array[Option[EntityRef]]()
  
  override def copy = {
    val copy = new SpellSlots()
    val newArray = Array.fill[Option[EntityRef]](slots.size) { None }
    
    for (index <- 0 to slots.size) {
      if (slots.isDefinedAt(index)) {
        newArray(index) = Option(slots(index).get.copy)
      }
    }
    
    copy.slots = newArray
    copy
  }
}